package com.zh.onlineexam.config;

import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author 29934
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
    @Resource
    private CorsInterceptor corsInterceptor;

    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(corsInterceptor).addPathPatterns("/**");
        // 注册 Sa-Token 的路由拦截器
        registry.addInterceptor(new SaRouteInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/user/login");
                //.excludePathPatterns("/user/logout")
                //.excludePathPatterns("/user/getUserInfo")
                //.excludePathPatterns("/user/listAll")
                //.excludePathPatterns("/user/addUser")
                //.excludePathPatterns("/user/deleteUserById/{id}")
                //.excludePathPatterns("/tInfoTextContent/listAll/{subject}/{level}")
                //.excludePathPatterns("/tInfoTextContent/import")
                //.excludePathPatterns("/dailyTest/listAll/{subjectId}/{level}/{loginId}")
                //.excludePathPatterns("/dailyTest/updateExamRecord")
                //.excludePathPatterns("/dailyTest/listExamRecords")
                //.excludePathPatterns("/dailyTest/export/{realName}")
                //.excludePathPatterns("/wrong/listAll")
                //.excludePathPatterns("/wrong/deleteById/{id}");
    }
}
